#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：Employment_class 
@File    ：09_多线程使用非共享变量.py
@IDE     ：PyCharm 
@Author  ：XiaoDengYa
@Date    ：2021/6/9/009 19:29 
"""

from threading import Thread
import time
import threading

def dtest1():
    thread_name = threading.current_thread().name
    print("------thread nam is %s----"%thread_name)
    g_num = 100
    if thread_name == "Thread-1":
        g_num += 1
    print("_____test1___g_num=%d"%g_num)
    time.sleep(2)
    print("_____test1___g_num=%d" % g_num)

def dtest2():
    time.sleep(1)
    g_num =100
    print("_____test2___g_num=%d"%g_num)

p1 = Thread(target=dtest1)
p1.start()
p2 = Thread(target=dtest1)
p2.start()